home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Lib / or / pe2or.py < prev    next >
Encoding:
Text File  |  1991-12-18  |  6.0 KB  |  301 lines

  1. -- pe2or: P1 O/R to OR_ptr conversion routines
  2.  
  3.  
  4. -- @(#) $Header: /xtel/pp/pp-beta/Lib/or/RCS/pe2or.py,v 6.0 1991/12/18 20:23:08 jpo Rel $
  5. --
  6. -- $Log: pe2or.py,v $
  7. -- Revision 6.0  1991/12/18  20:23:08  jpo
  8. -- Release 6.0
  9. --
  10. --
  11. --
  12.  
  13.  
  14. -- SEK add application 1 tag back into PE
  15.  
  16. OR DEFINITIONS ::=
  17.  
  18. %{
  19. #ifndef lint
  20. static char Rcsid[] = "@(#)$Header";
  21. #endif  lint
  22.  
  23. #include "util.h"
  24. #include "or.h"
  25.  
  26. extern char or_error[];
  27. static int or_concat ();
  28.  
  29. #define PEPYPARM        OR_ptr *
  30.  
  31. OR_ptr  pe2or (pe)
  32. PE      pe;
  33. {
  34.         OR_ptr  or = NULLOR;
  35.     PE  tpe;
  36.  
  37.         /* SEK put in an extra tage */
  38.     tpe = pe_alloc (PE_CLASS_APPL, PE_FORM_CONS, 0);
  39.     tpe -> pe_cons = pe;
  40.         if (decode_OR_ORName (tpe, 1, NULLIP, NULLVP, &or) == NOTOK) {
  41.                 if (or)
  42.                         or_free (or);
  43.         or = NULLOR;
  44.         }
  45.     tpe -> pe_cons = NULLPE;
  46.     pe_free (tpe);
  47.         return or;
  48. }
  49.  
  50. #undef DEBUG
  51. %}
  52.  
  53. BEGIN
  54.  
  55. DECODER decode
  56.  
  57. -- O/R name
  58.  
  59. ORName ::=
  60.         [APPLICATION 0]
  61.             IMPLICIT SEQUENCE {
  62.                 standard
  63.                     StandardAttributeList [[p parm]],
  64.  
  65.                 domaindefined
  66.                     DomainDefinedAttributeList [[p parm]] OPTIONAL
  67.             }
  68.  
  69. StandardAttributeList 
  70.         %{
  71.                 char    *str;
  72.         %} ::=
  73.         SEQUENCE {
  74.                 CountryName [[p parm]] OPTIONAL,
  75.  
  76.                 AdministrationDomainName [[p parm]] OPTIONAL,
  77.  
  78.             [0]
  79.                 IMPLICIT X121Address [[s str]]
  80.                 %{ if (or_concat (parm, OR_X121, NULLCP, str) == NOTOK)
  81.             return NOTOK;
  82.         %}
  83.                 OPTIONAL,
  84.  
  85.             [1]
  86.                 IMPLICIT TerminalID [[s str]]
  87.                 %{ if (or_concat (parm, OR_TID, NULLCP, str) == NOTOK)
  88.             return NOTOK;
  89.         %}
  90.                 OPTIONAL,
  91.  
  92.             [2]
  93.                 PrivateDomainName [[p parm]] OPTIONAL,
  94.  
  95.             [3]
  96.                 IMPLICIT OrganizationName [[s str]]
  97.                 %{ if (or_concat (parm, OR_O, NULLCP, str) == NOTOK)
  98.             return NOTOK;
  99.         %}
  100.                 OPTIONAL,
  101.  
  102.             [4]
  103.                 IMPLICIT UniqueUAIdentifier [[s str]]
  104.                 %{ if (or_concat (parm, OR_UAID, NULLCP, str) == NOTOK)
  105.             return NOTOK;
  106.         %}
  107.                 OPTIONAL,
  108.  
  109.             [5]
  110.                 IMPLICIT PersonalName [[p parm]] OPTIONAL,
  111.  
  112.             [6]
  113.                 IMPLICIT SEQUENCE OF OrganizationalUnit [[s str]]
  114.                 %{
  115.                         if (or_concat (parm, OR_OU, NULLCP, str) == NOTOK)
  116.                 return NOTOK;
  117.                 %}
  118.                 OPTIONAL
  119.         }
  120.  
  121.  
  122. DomainDefinedAttributeList ::=
  123.         SEQUENCE OF DomainDefinedAttribute [[p parm]]
  124.  
  125.  
  126. DomainDefinedAttribute
  127.         %{
  128.                 char    *dd_type, *dd_val;
  129.         %}
  130.         ::=
  131.         SEQUENCE {
  132.             type
  133.                 PrintableString [[s dd_type]],
  134.  
  135.             value
  136.                 PrintableString [[s dd_val]]
  137.         }
  138.         %{
  139.                 if (or_concat (parm, OR_DD, dd_type, dd_val) == NOTOK)
  140.             return NOTOK;
  141.         %}
  142.  
  143.  
  144. CountryName
  145.         %{
  146.                 char    *country;
  147.         %} ::=
  148.         [APPLICATION 1]
  149.             CHOICE {
  150.                 NumericString [[s country]],
  151.  
  152.                 PrintableString [[s country]]
  153.             }
  154.         %{
  155.                 if (or_concat (parm, OR_C, NULLCP, country) == NOTOK)
  156.             return NOTOK;
  157.         %}
  158.  
  159.  
  160. AdministrationDomainName
  161.         %{
  162.                 char    *admd;
  163.         %} ::=
  164.         [APPLICATION 2]
  165.             CHOICE {
  166.                 NumericString [[s admd]],
  167.                 PrintableString [[s admd]]
  168.             }
  169.         %{
  170.                 if (or_concat (parm, OR_ADMD, NULLCP, admd) == NOTOK)
  171.             return NOTOK;
  172.         %}
  173.  
  174.  
  175. PrivateDomainIdentifier
  176.         %{
  177.                 char    *prmd;
  178.         %} ::=
  179.         CHOICE {
  180.             NumericString [[s prmd]],
  181.  
  182.             PrintableString [[s prmd]]
  183.         }
  184.         %{
  185.                 if (or_concat (parm, OR_PRMD, NULLCP, prmd) == NOTOK)
  186.             return NOTOK;
  187.         %}
  188.  
  189. X121Address ::=
  190.         NumericString
  191.  
  192. TerminalID ::=
  193.         PrintableString
  194.  
  195. OrganizationName ::=
  196.         PrintableString
  197.  
  198. UniqueUAIdentifier ::=
  199.         NumericString
  200.  
  201. PersonalName
  202.         %{
  203.                 char    *str;
  204.         %} ::=
  205.         SET {
  206.             surName[0]
  207.                 IMPLICIT PrintableString [[s str]]
  208.                 %{
  209.                         if (or_concat (parm, OR_S, NULLCP, str) == NOTOK)
  210.                 return NOTOK;
  211.                 %},
  212.  
  213.             givenName[1]
  214.                 IMPLICIT PrintableString [[s str]]
  215.                 %{
  216.                         if (or_concat (parm, OR_G, NULLCP, str) == NOTOK)
  217.                 return NOTOK;
  218.                 %}
  219.                 OPTIONAL,
  220.  
  221.             initials[2]
  222.                 IMPLICIT PrintableString [[s str]]
  223.                 %{
  224.                         if (or_concat (parm, OR_I, NULLCP, str) == NOTOK)
  225.                 return NOTOK;
  226.                 %}
  227.                 OPTIONAL,
  228.  
  229.             generalQualifier[3]
  230.                 IMPLICIT PrintableString [[s str]]
  231.                 %{
  232.                         if (or_concat (parm, OR_GQ, NULLCP, str) == NOTOK)
  233.                 return NOTOK;
  234.                 %}
  235.                 OPTIONAL
  236.     }
  237.  
  238.  
  239. OrganizationalUnit ::=
  240.         PrintableString
  241.  
  242. PrivateDomainName
  243.         %{
  244.                 char *prmd;
  245.         %} ::=
  246.         CHOICE {
  247.             NumericString [[s prmd]],
  248.  
  249.             PrintableString [[s prmd]]
  250.         }
  251.         %{ if (or_concat (parm, OR_PRMD, NULLCP, prmd) == NOTOK)
  252.         return NOTOK;
  253.     %}
  254.  
  255.  
  256.  
  257.  
  258. END
  259.  
  260. %{
  261.  
  262.  
  263.  
  264. static int    or_concat (orp, type, str1, str2)
  265. OR_ptr  *orp;
  266. int     type;
  267. char    *str1, *str2;
  268. {
  269.         OR_ptr  or1, 
  270.         or2;
  271.  
  272.         if (*orp == NULLOR) {
  273.                 *orp = or_new (type, str1, str2);
  274.         if (*orp == NULLOR)
  275.             return NOTOK;
  276.     }
  277.         else {
  278.                 or1 = or_new (type, str1, str2);
  279.         if (or1 == NULLOR) {
  280.             (void) strcpy (PY_pepy, or_error);
  281.             return NOTOK;
  282.         }
  283.  
  284.         if (type == OR_OU)
  285.             or2 = or_add (*orp, or1, FALSE);
  286.         else 
  287.             or2 = or_add (*orp, or1, TRUE);
  288.  
  289.         if (or2 != NULLOR)
  290.             *orp = or2;
  291.         else {
  292.             PP_LOG (LLOG_EXCEPTIONS, ("or_add failed on %s %s",
  293.                 str1 ? str1 : "", str2 ? str2 : "" ));
  294.             return NOTOK;
  295.         }
  296.         }
  297.     return OK;
  298. }
  299.  
  300. %}
  301.